<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="author" content="" />
    <link href="view/css/style.css" type="text/css" rel="stylesheet"/>
    <link href="css/tooltip.css" type="text/css" rel="stylesheet"/>
    
    <link rel="stylesheet" href="../jquery.tooltip.css" />
    <script src="js/tooltip/lib/jquery.js" type="text/javascript"></script>
    <script src="js/tooltip/lib/jquery.bgiframe.js" type="text/javascript"></script>
    <script src="js/tooltip/lib/jquery.dimensions.js" type="text/javascript"></script>
    <script src="js/tooltip/jquery.tooltip.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" src="view/js/ajax-dynamic-content.js"></script>
    <script type="text/javascript" language="javascript" src="view/js/ajax.js"></script>
    <script type="text/javascript" language="javascript" src="view/js/ajax-tooltip.js" defer="defer"></script>
    
	
</head>

<?php
	 include("model/database.php");
        include("model/products.php");
	 
	 $tbl = new products();
	 if(isset($_GET['cate']))
		{
			$cate_id = $_GET['cate'];
			$row = $tbl->show_biding_product_by_cate($cate_id);
			$row_ending = $tbl->show_ending_auction_by_cate($cate_id);	  
		}
	else
		{
			$row = $tbl->show_all_product();
			$row_ending = $tbl->show_ending_auction();	
		}
         $userTool = new UserTools();
         $total = $userTool->countAllproduct();
	 ?>
        
<body>
<div id="blockContent-wrapper">
	<div class="titlepro">
            	Live Auctions Product
    </div>
	<div class="blockContent">
		<?php 
        
        foreach($row as $row_pro)
        {
          
        ?>	
	
		<div class="blockProduct">
				<!--<div class="containerImage">
					<?php  echo $row_pro['pro_name']; ?>
				</div>-->
			
			<div class="MostbgItem">              
                 <div class ="title-pro">
                     <a href="bidProduct.php?pro_id=<?php  echo $row_pro['pro_id']; ?>" class = "amostitem" target="_self" onmouseover = " VietAd_ShowTooltip('view/popup/productdetail.php?memberid=<?php echo $row_pro['pro_id']?>');
                return false;" onmouseout="VietAd_HideTooltip();" >
						<?php  
							$name  =  $row_pro['pro_name'];
							echo $name = substr($name, 0,28)." ..."; 
						?>
					</a>
				</div>
                <div class="containerImage">
                     <a href="bidProduct.php?pro_id=<?php  echo $row_pro['pro_id']; ?>" class = "amostitem" target="_self" onmouseover = " VietAd_ShowTooltip('view/popup/productdetail.php?memberid=<?php echo $row_pro['pro_id']?>');
                return false;" onmouseout="VietAd_HideTooltip();" >
                         <img src="<?php echo "images-products/thumbnail/$row_pro[pro_image1]" ?>" />
                     </a>
                </div>
                <div class="count">
                    <h3></h3>
                </div>
 				<div class="containerPrice">
					<span class="price">$ <?php echo $row_pro['pro_prince']; ?></span>     	
				</div>
				<div class="member-name">
                   <?php //echo $row_pro['firstname']?>
                </div>
                <div class="btn-bid">
                   <img src="images-products/thumbnail/btn_bid.png" width="80px" height="30" />
                </div>
   			</div>
			<div class="clearfix"></div>
		</div>
	<?php }?>
    <div class="clearfix"></div>
    </div>
    
    <div class="titlepro">
            	Ending Auctions Product
    </div>
    <div class="blockContent">
		<?php 
        
        foreach($row_ending as $row_pro_end)
        {
          
        ?>	
	
		<div class="blockProduct">
				
			<div class="MostbgItem">              
                 <div class ="title-pro">
                     <a href="endProduct.php?pro_id=<?php  echo $row_pro_end['pro_id']; ?>" class = "amostitem" target="_self" onmouseover = " VietAd_ShowTooltip('view/popup/index.php?memberid=<?php echo $row_pro_end['pro_id']?>');
                return false;" onmouseout="VietAd_HideTooltip();" >
						<?php  
							$name  =  $row_pro_end['pro_name'];
							echo $name = substr($name, 0,28)." ..."; 
						?>
					</a>
				</div>
                <div class="containerImage">
                     <a href="endProduct.php?pro_id=<?php  echo $row_pro_end['pro_id']; ?>" class = "amostitem" target="_self" onmouseover = " VietAd_ShowTooltip('view/popup/index.php?memberid=<?php echo $row_pro_end['pro_id']?>');
                return false;" onmouseout="VietAd_HideTooltip();" >
                         <img src="<?php echo "images-products/thumbnail/$row_pro_end[pro_image1]" ?>" />
                     </a>
                </div>
 				<div class="count-end">
                    <h3>Ended</h3>
                </div>
 				<div class="containerPrice">
					<span class="price">$ <?php echo $row_pro['pro_prince']; ?></span>     	
				</div>
				<div class="member-name">
                    <?php echo $row_pro_end['firstname']?>
                </div>
                <div class="btn-bid">
                   <img src="images-products/thumbnail/btn_bid.png" width="80px" height="30" />
                </div>
   			</div>
			<div class="clearfix"></div>
		</div>
	<?php }?>
    <div class="clearfix"></div>
    </div>
</div>
<script type="text/javascript">
    var interval;
    var minutes = 0;
    var seconds = 20;
    var total = <?php echo $total; ?>;
    window.onload = function() {
        countdown('h3');
    }
    function countdown(element) {
        interval = setInterval(function() {
            var el = document.getElementsByTagName('h3');
            if(seconds < 10)
            {
                for(var i=0;i<total;i++)
                    {
                        el[i].style.color ="red";
                    }
            }
            else 
            {
                    for(var i=0;i<total;i++)
                    {
                        el[i].style.color ="black";
                    }
            }
            if(seconds == 0) {
                if(minutes == 0) {
                	window.location.reload();
                    return;
                } else {
                    minutes--;
                    seconds = 60;
                }
            }
            if(minutes > 0) {
                var minute_text = minutes + (minutes > 1 ? ':' : ':');
            } else {
                var minute_text = '00:';
            }
            
            for(var i=0;i<total;i++)
            {
                el[i].innerHTML ='00:' + minute_text + seconds;
            }
            seconds--;

        }, 1000);
    }
</script> 
</body>
</html>